package org.orqlog.client;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class NettyClientHandler extends SimpleChannelInboundHandler<String> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, String msg)
            throws Exception {
            if (msg.contains("关闭")) {
                ctx.close();
            }
//        if (msg.contains("系统退出")) {
//            ctx.close();
//
//        } else {
//            ctx.writeAndFlush("aaa");
//            ctx.writeAndFlush("bye");
//        }
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
        cause.printStackTrace();
        ctx.close();
    }
}
